package setup

import (
	"fmt"
	"go_auth/ext/settings"
	"go_auth/routers"
	"go_auth/servers/users"
	"net/http"
	"time"
)

func SetUp(path string) {
	settings.SetUpConf(path)
	users.GetAllUserPer()
	users.InitPer()

}

func Web() {
	router := routers.InitRouter()

	s := &http.Server{
		Addr:           fmt.Sprintf(":%d", int(settings.ServerBase.HttpPort)),
		Handler:        router,
		ReadTimeout:    time.Duration(settings.ServerBase.ReadTimeOut) * time.Second,
		WriteTimeout:   time.Duration(settings.ServerBase.WriteTimeOut) * time.Second,
		MaxHeaderBytes: 1 << 20,
	}

	s.ListenAndServe()
}
